<?php

class BaseAction extends Action {
	//判断用户是否登录
	/* public function _initialize(){
		$group = __GROUP__;
 		if($group=="/a130427/Admin" || $group=="/Admin"){//如果不是默认分组 则判断用户是否已经登录
			if (!isset($_SESSION['userInfo']) && !isset($_REQUEST['session'])){
				if(end(explode("/",__ACTION__))!="uploadScenic"){//景区图片上传 不验证权限
					$this->assign('jumpUrl',__APP__.'/Login/login'); // 设置提示后跳转页面
					$this->error('请先登录！');
				}
			}
 		}
	} */
	
	// 文件上传
	protected function _upload() {
        import("@.ORG.UploadFile");
        //导入上传类
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize = 10240000;
        //设置上传文件类型
        $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
        //设置附件上传目录
        $upload->savePath = 'Public/uploads/'.MODULE_NAME."/";
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb = true;
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';
        //设置需要生成缩略图的文件后缀
        $upload->thumbPrefix = 'm_,s_';  //生产2张缩略图
        //设置缩略图最大宽度
        $upload->thumbMaxWidth = '194,147';
        //设置缩略图最大高度
        $upload->thumbMaxHeight = '144,129';
        //设置上传文件规则
        $upload->saveRule = uniqid;
        //删除原图
//        $upload->thumbRemoveOrigin = false;
        if (!$upload->upload()) {
            //捕获上传异常
            $this->error($upload->getErrorMsg());
        } else {
            //取得成功上传的文件信息
            $info = $upload->getUploadFileInfo();
//            $_POST['image'] = $uploadList[0]['savename'];
            return $info;
        }
    }
    
    //获取用户信息
    public function userInfo(){
    	$user = session("userInfo");//获取用户信息
    	return $user;
    }
    
    //获取用户ID
    public function userID(){
    	$user = $this->userInfo();//获取用户信息
    	return $user["id"];
    }
    
}

?>